package com.rc.evcharger.common.notify;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * （没用到，统一使用MQ的广播模式推送）
 * 微信将订单消息推送
 * @author yang
 */
public class WeChatMsgUtil {
    static Logger logger = LoggerFactory.getLogger(WeChatMsgUtil.class);

    /**
     * 订单来源 0.公众号,1.app,2.小程序
     * @param orderSource
     * @param commandStopReq
     */
    //public static void sendFinishMsg(String orderSource, CommandStopReq commandStopReq) {
    //    if ("0".equals(orderSource) || "2".equals(orderSource) || "3".equals(orderSource)) { // 发送微信模版消息(正常完成订单)
    //        //            String weChatUrl = "https://saastest.jin-zhuang.cn/jinzhuang-saas-wechat/charge/sendFinishMsg";
    //        String weChatUrl = "https://gxkywx.jin-zhuang.cn/jinzhuang-saas-wechat/charge/sendFinishMsg";
    //        try {
    //            Request.Post(weChatUrl).bodyForm(new BasicNameValuePair("orderID", String.valueOf(commandStopReq.getOrderId()))).execute()
    //                    .handleResponse(new ResponseHandler<Object>() {
    //                        @Override
    //                        public Object handleResponse(HttpResponse httpResponse) throws IOException {
    //                            int code = httpResponse.getStatusLine().getStatusCode();
    //                            if (code != 200) {
    //                                return null;
    //                            }
    //                            String response = EntityUtils.toString(httpResponse.getEntity());
    //                            logger.info("发送微信模版消息(正常完成订单)=" + response + " orderId=" + commandStopReq.getOrderId());
    //                            return null;
    //                        }
    //                    });
    //        } catch (Exception e) {
    //            e.printStackTrace();
    //        }
    //    } else if (orderSource.equals("1")) {//APP订单发送短信
    //        String jsonData = JSON.toJSONString(commandStopReq);
    //        try {
    //            //                String appUrl = "http://app.jin-zhuang.cn/jzcharge-app/appNotify/app_query_stop_charge";
    //            //String appUrl = "http://localhost:8080/appNotify/app_query_stop_charge";
    //            String appUrl = "https://apps.jin-zhuang.cn/jzcharge-app/appNotify/app_query_stop_charge";
    //            Request.Post(appUrl)
    //                    .addHeader("Content-Type", "application/json;charset=UTF-8")
    //                    .body(new StringEntity(jsonData))
    //                    .execute()
    //                    .handleResponse(new ResponseHandler<Void>() {
    //                        @Override
    //                        public Void handleResponse(HttpResponse httpResponse) throws IOException {
    //                            int code = httpResponse.getStatusLine().getStatusCode();
    //                            logger.warn("APP 异常结算推送:{},:{},:{}", commandStopReq.getOrderNum(), appUrl, code);
    //
    //                            if (code != 200) {
    //                                logger.info("APP 结算订单推送失败:{}", commandStopReq.getOrderNum());
    //                            } else {
    //                                logger.info("APP 结算订单推送成功:{}", commandStopReq.getOrderNum());
    //                            }
    //                            return null;
    //                        }
    //                    });
    //        } catch (Exception e) {
    //            logger.info("APP 异常结算推送异常:{}", commandStopReq.getOrderNum());
    //        }
    //    }
    //}
    //
    //public static void sendErrorMsg(Long orderID) {
    //    // 发送微信模版消息(异常完成订单)
    //    //        String weChatUrl = "https://saastest.jin-zhuang.cn/jinzhuang-saas-wechat/charge/sendErrorMsg";
    //    String weChatUrl = "https://gxkywx.jin-zhuang.cn/jinzhuang-saas-wechat/charge/sendErrorMsg";
    //    try {
    //        Request.Post(weChatUrl).bodyForm(new BasicNameValuePair("orderID", orderID.toString())).execute()
    //                .handleResponse(new ResponseHandler<Object>() {
    //                    @Override
    //                    public Object handleResponse(HttpResponse httpResponse) throws IOException {
    //                        int code = httpResponse.getStatusLine().getStatusCode();
    //                        if (code != 200) {
    //                            return null;
    //                        }
    //                        String response = EntityUtils.toString(httpResponse.getEntity());
    //                        logger.info("发送微信模版消息(异常完成订单)=" + response + " orderId=" + orderID);
    //                        return null;
    //                    }
    //                });
    //    } catch (Exception e) {
    //        e.printStackTrace();
    //    }
    //}
}
